package com.mxpio.erp.common.inventory.service;

import com.mxpioframework.common.vo.Result;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import com.mxpio.erp.common.inventory.entity.SupplyChain;
import com.mxpio.erp.common.order.policy.OrderContext;
import com.mxpio.erp.common.purchase.entity.Supply;
import com.mxpio.erp.common.technology.entity.Item;
import com.mxpio.erp.common.vo.SupplyChainVo;
import com.mxpioframework.jpa.query.Criteria;
import com.mxpioframework.system.service.BaseService;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface SupplyChainService extends BaseService<SupplyChain> {

	/**
	 * 按供应商列出供应链信息
	 * @param pageAble
	 * @param c
	 * @return
	 */
	Page<Supply> pageBySupply(Pageable pageAble, Criteria c);

	/**
	 * 按物料列出供应链信息
	 * @param pageAble
	 * @param c
	 * @return
	 */
	Page<Item> pageByItem(Pageable pageAble, Criteria c);

	/**
	 * 按供应商删除供应链信息
	 * @param pnCode
	 * @param itemCode
	 * @return
	 */
	int removeBySupply(String pnCode, Object[] itemCode);

	/**
	 * 按物料删除供应链信息
	 * @param itemCode
	 * @param pnCode
	 * @return
	 */
	int removeByItem(String itemCode, Object[] pnCode);

	/**
	 * 批量修改供应链按供应商
	 * @param pnCode
	 * @param itemCode
	 * @param supplyChainVo
	 * @return
	 */
	int editBatchBySupply(String pnCode, Object[] itemCode, SupplyChainVo supplyChainVo);

	/**
	 * 批量修改供应链按物料
	 * @param itemCode
	 * @param pnCode
	 * @param supplyChainVo
	 * @return
	 */
	int editBatchByItem(String itemCode, Object[] pnCode, SupplyChainVo supplyChainVo);

	/**
	 * 确认供应链信息
	 * @param context
	 */
	void check(OrderContext context);

	/**
	 * 获取未匹配的物料列表
	 * @param pnCode
	 * @param pageAble
	 * @param c
	 * @return
	 */
	Page<Item> withoutItemBySupply(String pnCode, Pageable pageAble, Criteria c);

	/**
	 * 获取未匹配的供应商列表
	 * @param itemCode
	 * @param pageAble
	 * @param c
	 * @return
	 */
	Page<Supply> withoutSupplyByItem(String itemCode, Pageable pageAble, Criteria c);


    List<Supply> getSupplysByItemCodes(String[] itemCode);

	@Transactional(readOnly = true)
	List<Supply> getMachinedSupplysByItemCodes(String[] itemCode);

	Page<Item> pnCodeOwnedItemsPage(Pageable pageAble, Criteria criteria, String pnCode);

    Result<Item> getItemPrice(String itemCode, String pnCode);

	List<Supply> getOneSupplysByItemCodes(String itemCode);
}
